﻿using CL.Enum.Common.Special;
using CL.Game.BLL;
using CL.Game.BLL.Tools;
using CL.Game.Entity;
using CL.Tools.Common;
using CL.View.Entity.Game;
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace CL.Tools.LotteryTickets.Special
{
    public class XY28 : LotteryBase
    {
        #region 变量
        protected XmlNode Xml = null;
        protected const int LotteryCode = 40010;
        protected IsusesBLL IssueBLL = new IsusesBLL();
        protected SchemesBLL SchemeBLL = new SchemesBLL();
        protected SchemesWinBLL WinBLL = new SchemesWinBLL();
        protected WinTypesBLL WintypeBLL = new WinTypesBLL();
        protected SchemeETicketsBLL TicketBLL = new SchemeETicketsBLL();
        #endregion
        Log log = new Log("XY28");
        public XY28()
        {
            GetWinType();
        }
        public XY28(XmlNode _xml)
        {
            Xml = _xml;
            GetWinType();
        }
        private void GetWinType()
        {
            List<WinTypesEntity> Entitys = WintypeBLL.QueryList(LotteryCode);
            foreach (WinTypesEntity item in Entitys)
                wt.Add(new WinType()
                {
                    DefaultMoney = Convert.ToInt32(item.DefaultMoney),
                    DefaultMoneyNoWithTax = Convert.ToInt32(item.DefaultMoneyNoWithTax),
                    PlayCode = Convert.ToInt32(item.PlayCode),
                    WinCode = Convert.ToInt32(item.WinCode),
                    WinName = item.WinName
                });
        }
        #region 采集开奖数据
        public override LotteryResult GetValue()
        {
            LotteryResult ent = new LotteryResult();
            try
            {
                ent = GetValue1();
                if (ent != null)
                {
                    #region 新的开奖方式
                    string ReturnDescription = "";
                    bool res = IssueBLL.EnteringDrawResults(ent.LotteryCode, ent.IsuseName, ent.LotteryWinNum, ent.LotteryTime, ref ReturnDescription);
                    if (res)
                    {
                        if (ReturnDescription.Trim() == "添加开奖信息成功" && !string.IsNullOrEmpty(ent.LotteryWinNum))
                        {
                            IssueBLL.InsertIsuseInfoRedis(ent.LotteryCode, ent.IsuseName, ent.LotteryWinNum, ent.StartTime, ent.EndTime, ent.LotteryTime, 0, 0);
                        }
                        Console.WriteLine(string.Format("抓取开奖结果：{0}", ent.ToString()));
                    }
                    #endregion
                }
                else
                {
                    ent = GetValue2();
                    if (ent != null)
                    {
                        #region 新的开奖方式
                        string ReturnDescription = "";
                        bool res = IssueBLL.EnteringDrawResults(ent.LotteryCode, ent.IsuseName, ent.LotteryWinNum, ent.LotteryTime, ref ReturnDescription);
                        if (res)
                        {
                            if (ReturnDescription.Trim() == "添加开奖信息成功" && !string.IsNullOrEmpty(ent.LotteryWinNum))
                            {
                                IssueBLL.InsertIsuseInfoRedis(ent.LotteryCode, ent.IsuseName, ent.LotteryWinNum, ent.StartTime, ent.EndTime, ent.LotteryTime, 0, 0);
                            }
                            Console.WriteLine(string.Format("抓取开奖结果：{0}", ent.ToString()));
                        }
                        #endregion
                    }
                }
                return ent;
            }
            catch (Exception ex)
            {
                log.Write("读取XML数据失败,错误日志:" + ex.Message, true);
                return null;
            }
        }

        protected LotteryResult GetValue1()
        {
            try
            {
                LotteryResult ent = new LotteryResult();
                TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 8, 0, 0, 0);
                string url = string.Format("http://kaijiang.500.com/static/info/kaijiang/xml/kl8/{0}.xml?_A=QZBLNMUO{1}", DateTime.Now.ToString("yyyyMMdd"), Convert.ToInt64(ts.TotalMilliseconds).ToString());
                string Xml = HttpProxy.HttpGetProxy(url);
                if (string.IsNullOrEmpty(Xml))
                    return null;

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(Xml);
                XmlNodeList NodeList = doc.SelectNodes("xml/row");
                if (NodeList != null && NodeList.Count > 0)
                {
                    string OutXml = NodeList[0].OuterXml;
                    int opentime_start = OutXml.IndexOf("opentime=") + ("opentime").Length + 2;
                    int opentime_end = OutXml.IndexOf("/>") - 2;

                    int opencode_start = OutXml.IndexOf("opencode=") + ("opencode").Length + 2;
                    int opencode_end = OutXml.IndexOf("specail=") - 2;

                    int expect_start = OutXml.IndexOf("expect=") + ("expect").Length + 2;
                    int expect_end = OutXml.IndexOf("opencode") - 2;
                    
                    ent.LotteryCode = LotteryCode;
                    ent.IsuseName = OutXml.Substring(expect_start, expect_end - expect_start);
                    ent.LotteryTime = Convert.ToDateTime(OutXml.Substring(opentime_start, opentime_end - opentime_start));
                    ent.LotteryWinNum = OutXml.Substring(opencode_start, opencode_end - opencode_start).Replace(",", " ");
                    return ent;
                }
                return null;
            }
            catch
            {
                return null;
            }
        }
        /// <summary>
        /// 抓取地址 360彩票
        /// </summary>
        /// <returns></returns>
        protected LotteryResult GetValue2()
        {
            try
            {
                LotteryResult ent = new LotteryResult();
                string url = string.Format("http://chart.cp.360.cn/kaijiang/kl8/?r_a=fEnaqq");
                string htmlContent = HttpProxy.HttpGetProxy(url);
                HtmlDocument doc = new HtmlDocument();
                doc.LoadHtml(htmlContent);
                if (string.IsNullOrEmpty(htmlContent))
                    return null;
                HtmlNode collection = doc.DocumentNode.SelectSingleNode("//tbody[@id='data-tab']");

                ent.LotteryCode = LotteryCode;
                ent.IsuseName = Convert.ToString(collection.ChildNodes[0].ChildNodes[1].InnerText.Trim());
                ent.LotteryTime = Convert.ToDateTime(collection.ChildNodes[0].ChildNodes[5].InnerText.Trim());
                ent.LotteryWinNum = collection.ChildNodes[0].ChildNodes[2].InnerText.Replace("&nbsp;", " ").Trim();
                return ent;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        #endregion
        #region 采集遗漏号码
        public override void GetSuppNum()
        {
            try
            {
                GetSuppNum1();  //接口获取开奖数据
            }
            catch (Exception ex)
            {
                log.Write("采集遗漏号码失败,错误日志:" + ex.Message, true);
            }
        }
        protected void GetSuppNum1()
        {
            LotteryResult ent = new LotteryResult();
            TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 8, 0, 0, 0);
            string url = string.Format("https://kaijiang.500.com/static/info/kaijiang/xml/kl8/{0}.xml?_A=QZBLNMUO{1}", DateTime.Now.ToString("yyyyMMdd"), Convert.ToInt64(ts.TotalMilliseconds).ToString());
            string Xml = HttpProxy.HttpGetProxy(url);
            if (string.IsNullOrEmpty(Xml))
                return;

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(Xml);
            XmlNodeList NodeList = doc.SelectNodes("xml/row");
            foreach (XmlNode item in NodeList)
            {
                try
                {
                    string OutXml = item.OuterXml;
                    int opentime_start = OutXml.IndexOf("opentime=") + ("opentime").Length + 2;
                    int opentime_end = OutXml.IndexOf("/>") - 2;

                    int opencode_start = OutXml.IndexOf("opencode=") + ("opencode").Length + 2;
                    int opencode_end = OutXml.IndexOf("specail=") - 2;

                    int expect_start = OutXml.IndexOf("expect=") + ("expect").Length + 2;
                    int expect_end = OutXml.IndexOf("opencode") - 2;
                    
                    ent.LotteryCode = LotteryCode;
                    ent.IsuseName = OutXml.Substring(expect_start, expect_end - expect_start);
                    ent.LotteryTime = Convert.ToDateTime(OutXml.Substring(opentime_start, opentime_end - opentime_start));
                    ent.LotteryWinNum = OutXml.Substring(opencode_start, opencode_end - opencode_start).Replace(",", " ");

                    string ReturnDescription = "";
                    bool res = IssueBLL.EnteringDrawResults(ent.LotteryCode, ent.IsuseName, ent.LotteryWinNum, ent.LotteryTime, ref ReturnDescription);
                    if (res)
                    {
                        if (ReturnDescription.Trim() == "添加开奖信息成功" && !string.IsNullOrEmpty(ent.LotteryWinNum))
                        {
                            IssueBLL.InsertIsuseInfoRedis(ent.LotteryCode, ent.IsuseName, ent.LotteryWinNum, ent.StartTime, ent.EndTime, ent.LotteryTime, 0, 0);
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.Write("采集遗漏号码失败,错误日志:" + ex.Message, true);
                }
            }
        }
        #endregion
        #region 奖等算奖
        /// <summary>
        /// 处理开奖号码
        /// </summary>
        /// <param name="OpenNum">开奖号码</param>
        /// <param name="SpecialNum">特殊号码</param>
        /// <param name="OpenSum">开奖号码和值</param>
        /// <returns></returns>
        private int[] SetAwardNumber(int[] OpenNum, ref int SpecialNum, ref int OpenSum)
        {
            //从小到大的顺序依次排列开奖号码
            //取1-6位开奖号码相加的和值尾作为幸运28第1位开奖号码
            //取7-12位开奖号码相加的和值尾作为幸运28第2位开奖号码
            //取13-18位开奖号码相加的和值尾作为幸运28第3位开奖号码
            OpenNum = OpenNum.OrderBy(o => o).ToArray();
            int OpenNum1 = 0;
            int OpenNum2 = 0;
            int OpenNum3 = 0;
            for (int i = 0; i < 6; i++)
                OpenNum1 += OpenNum[i];
            for (int i = 6; i < 12; i++)
                OpenNum2 += OpenNum[i];
            for (int i = 12; i < 18; i++)
                OpenNum3 += OpenNum[i];
            //特殊号码
            string SpecialNum_Ext = (OpenNum[18] + OpenNum[19]).ToString();
            SpecialNum = Convert.ToInt32(SpecialNum_Ext.Substring(SpecialNum_Ext.Length - 1, 1));
            //开奖号码和值
            int[] OpenNumber = new int[] { Convert.ToInt32(OpenNum1.ToString().Substring(OpenNum1.ToString().Length - 1, 1)),
                                           Convert.ToInt32(OpenNum2.ToString().Substring(OpenNum2.ToString().Length - 1, 1)),
                                           Convert.ToInt32(OpenNum3.ToString().Substring(OpenNum3.ToString().Length - 1, 1))};
            //开奖号码和值
            OpenSum = OpenNumber.Sum();
            return OpenNumber;
        }
        #region 玩法算奖
        /// <summary>
        /// 大小单双
        /// </summary>
        /// <param name="Number">投注号码</param>
        /// <param name="OpenNumber">开奖号码</param>
        /// <param name="BuyAmount">投注金额</param>
        /// <param name="Description">备注</param>
        /// <param name="WinMoneyNoWithTax">税后中奖金额</param>
        /// <returns></returns>
        public long ComputeWin_DXDS(string Number, string OpenNumber, long BuyAmount, ref int WinCode, ref string Description, ref long WinMoneyNoWithTax)
        {
            //所有都是单式投注
            int[] OpenNum = OpenNumber.Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
            //特殊号码
            int SpecialNum = -1;
            //开奖号码和值
            int OpenSum = -1;
            //计算开奖号码
            OpenNum = SetAwardNumber(OpenNum, ref SpecialNum, ref OpenSum);

            //开奖号码和值
            int Description1 = 0;
            long WinMoney = 0;
            WinType model = null;
            switch (Number.Trim())
            {
                case "大":
                    //14~27
                    if (OpenSum >= 14 && OpenSum <= 27)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_DA && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_DA;
                    }
                    break;
                case "小":
                    //0~13
                    if (OpenSum >= 0 && OpenSum <= 13)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_X && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_X;
                    }
                    break;
                case "单":
                    //1,3,5,7,9,11,13,15,17,19,21,23,25,27
                    if ((OpenSum % 2) != 0)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_DAN && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_DAN;
                    }
                    break;
                case "双":
                    //0,2,4,6,8,10,12,14,16,18,20,22,24,26
                    if ((OpenSum % 2) == 0)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_S && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_S;
                    }
                    break;
                case "极大":
                    //22,23,24,25,26,27
                    if (OpenSum >= 22 && OpenSum <= 27)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_JD && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_JD;
                    }
                    break;
                case "大单":
                    //15,17,19,21,23,25,27
                    if (OpenSum == 15 || OpenSum == 17 || OpenSum == 19 || OpenSum == 21 || OpenSum == 23 || OpenSum == 25 || OpenSum == 27)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_DD && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_DD;
                    }
                    break;
                case "小单":
                    //1,3,5,7,9,11,13
                    if (OpenSum == 1 || OpenSum == 3 || OpenSum == 5 || OpenSum == 7 || OpenSum == 9 || OpenSum == 11 || OpenSum == 13)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_XD && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_XD;
                    }
                    break;
                case "大双":
                    //14,16,18,20,22,24,26
                    if (OpenSum == 14 || OpenSum == 16 || OpenSum == 18 || OpenSum == 20 || OpenSum == 22 || OpenSum == 24 || OpenSum == 26)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_DS && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_DS;
                    }
                    break;
                case "小双":
                    //0,2,4,6,8,10,12
                    if (OpenSum == 0 || OpenSum == 2 || OpenSum == 4 || OpenSum == 6 || OpenSum == 8 || OpenSum == 10 || OpenSum == 12)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_XS && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_XS;
                    }
                    break;
                case "极小":
                    //0,1,2,3,4,5
                    if (OpenSum >= 0 && OpenSum <= 5)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_JX && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_JX;
                    }
                    break;
            }
            if (Description1 > 0)
                Description = "大小单双," + Description1 + "注。";
            return WinMoney;
        }
        /// <summary>
        /// 猜数字
        /// </summary>
        /// <param name="Number">投注号码</param>
        /// <param name="OpenNumber">开奖号码</param>
        /// <param name="BuyAmount">投注金额</param>
        /// <param name="Description">备注</param>
        /// <param name="WinMoneyNoWithTax">税后中奖金额</param>
        /// <returns></returns>
        public long ComputeWin_CSZ(string Number, string OpenNumber, long BuyAmount, ref int WinCode, ref string Description, ref long WinMoneyNoWithTax)
        {
            //所有都是单式投注
            int[] OpenNum = OpenNumber.Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
            //特殊号码
            int SpecialNum = -1;
            //开奖号码和值
            int OpenSum = -1;
            //计算开奖号码
            OpenNum = SetAwardNumber(OpenNum, ref SpecialNum, ref OpenSum);

            //开奖号码和值
            int Description1 = 0;
            long WinMoney = 0;
            WinType model = null;
            if (Convert.ToInt32(Number) == OpenSum)
            {
                switch (Number.Trim())
                {
                    case "0":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_0 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_0;
                        break;
                    case "1":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_1 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_1;
                        break;
                    case "2":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_2 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_2;
                        break;
                    case "3":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_3 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_3;
                        break;
                    case "4":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_4 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_4;
                        break;
                    case "5":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_5 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_5;
                        break;
                    case "6":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_6 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_6;
                        break;
                    case "7":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_7 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_7;
                        break;
                    case "8":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_8 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_8;
                        break;
                    case "9":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_9 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_9;
                        break;
                    case "10":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_10 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_10;
                        break;
                    case "11":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_11 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_11;
                        break;
                    case "12":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_12 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_12;
                        break;
                    case "13":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_13 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_13;
                        break;
                    case "14":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_14 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_14;
                        break;
                    case "15":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_15 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_15;
                        break;
                    case "16":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_16 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_16;
                        break;
                    case "17":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_17 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_17;
                        break;
                    case "18":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_18 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_18;
                        break;
                    case "19":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_19 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_19;
                        break;
                    case "20":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_20 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_20;
                        break;
                    case "21":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_21 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_21;
                        break;
                    case "22":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_22 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_22;
                        break;
                    case "23":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_23 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_23;
                        break;
                    case "24":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_24 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_24;
                        break;
                    case "25":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_25 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_25;
                        break;
                    case "26":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_26 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_26;
                        break;
                    case "27":
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.CSZ_27 && p.PlayCode == (int)XYEB_PlayCodeEnum.CSZ);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.CSZ_27;
                        break;
                }
            }
            if (Description1 > 0)
                Description = "猜数字," + Description1 + "注。";
            return WinMoney;
        }
        /// <summary>
        /// 趣味玩
        /// </summary>
        /// <param name="Number">投注号码</param>
        /// <param name="OpenNumber">开奖号码</param>
        /// <param name="BuyAmount">投注金额</param>
        /// <param name="Description">备注</param>
        /// <param name="WinMoneyNoWithTax">税后中奖金额</param>
        /// <returns></returns>
        public long ComputeWin_QWW(string Number, string OpenNumber, long BuyAmount, ref int WinCode, ref string Description, ref long WinMoneyNoWithTax)
        {
            //所有都是单式投注
            int[] OpenNum = OpenNumber.Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
            //特殊号码
            int SpecialNum = -1;
            //开奖号码和值
            int OpenSum = -1;
            //分组数字
            int GroupNum = -1;
            //计算开奖号码
            OpenNum = SetAwardNumber(OpenNum, ref SpecialNum, ref OpenSum);

            //开奖号码和值
            int Description1 = 0;
            long WinMoney = 0;
            WinType model = null;
            switch (Number.ToString())
            {
                case "红":
                    //3,6,9,15,18,21,24
                    if (OpenSum == 3 || OpenSum == 6 || OpenSum == 9 || OpenSum == 15 || OpenSum == 18 || OpenSum == 21 || OpenSum == 24)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.QWW_H && p.PlayCode == (int)XYEB_PlayCodeEnum.QWW);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.QWW_H;
                    }
                    break;
                case "绿":
                    //1,4,7,10,16,19,22,25
                    if (OpenSum == 1 || OpenSum == 4 || OpenSum == 7 || OpenSum == 10 || OpenSum == 16 || OpenSum == 19 || OpenSum == 22 || OpenSum == 25)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.QWW_LV && p.PlayCode == (int)XYEB_PlayCodeEnum.QWW);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.QWW_LV;
                    }
                    break;
                case "蓝":
                    //2,5,8,11,17,20,23,26
                    if (OpenSum == 2 || OpenSum == 5 || OpenSum == 8 || OpenSum == 11 || OpenSum == 17 || OpenSum == 20 || OpenSum == 23 || OpenSum == 26)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.QWW_LAN && p.PlayCode == (int)XYEB_PlayCodeEnum.QWW);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.QWW_LAN;
                    }
                    break;
                case "豹子":
                    //三个数字相同
                    GroupNum = OpenNum.GroupBy(g => g).Select(s => s.Key).ToArray().Length;
                    if (GroupNum == 1)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.QWW_BAO && p.PlayCode == (int)XYEB_PlayCodeEnum.QWW);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.QWW_BAO;
                    }
                    break;
                case "顺子":
                    //从小到大排列递增
                    OpenNum = OpenNum.OrderBy(o => o).ToArray();
                    if (OpenNum[0] + 1 == OpenNum[1] && OpenNum[1] + 1 == OpenNum[2])
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.QWW_SHUN && p.PlayCode == (int)XYEB_PlayCodeEnum.QWW);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.QWW_SHUN;
                    }
                    break;
                case "对子":
                    //两个数字相同 不包含豹子
                    GroupNum = OpenNum.GroupBy(g => g).Select(s => s.Key).ToArray().Length;
                    if (GroupNum == 2)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.QWW_DUI && p.PlayCode == (int)XYEB_PlayCodeEnum.QWW);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.QWW_DUI;
                    }
                    break;
            }
            if (Description1 > 0)
                Description = "趣味玩," + Description1 + "注。";
            return WinMoney;
        }
        /// <summary>
        /// 大小单双-特别号码
        /// </summary>
        /// <param name="Number">投注号码(大小单双,特殊数字)</param>
        /// <param name="OpenNumber">开奖号码</param>
        /// <param name="BuyAmount">投注金额</param>
        /// <param name="Description">备注</param>
        /// <param name="WinMoneyNoWithTax">税后中奖金额</param>
        /// <returns></returns>
        public long ComputeWin_DXDS_TBHM(string Number, string OpenNumber, long BuyAmount, ref int WinCode, ref string Description, ref long WinMoneyNoWithTax)
        {
            //所有都是单式投注
            int[] OpenNum = OpenNumber.Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
            //特殊号码
            int SpecialNum = -1;
            //开奖号码和值
            int OpenSum = -1;
            //计算开奖号码
            OpenNum = SetAwardNumber(OpenNum, ref SpecialNum, ref OpenSum);

            string[] BuyNumber = Number.Split(',');
            //开奖号码和值
            int Description1 = 0;
            long WinMoney = 0;
            WinType model = null;
            switch (BuyNumber[0].Trim())
            {
                case "大":
                    //14~27
                    if (OpenSum >= 14 && OpenSum <= 27)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_DA && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_DA;
                    }
                    break;
                case "小":
                    //0~13
                    if (OpenSum >= 0 && OpenSum <= 13)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_X && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_X;
                    }
                    break;
                case "单":
                    //1,3,5,7,9,11,13,15,17,19,21,23,25,27
                    if ((OpenSum % 2) != 0)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_DAN && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_DAN;
                    }
                    break;
                case "双":
                    //0,2,4,6,8,10,12,14,16,18,20,22,24,26
                    if ((OpenSum % 2) == 0)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_S && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_S;
                    }
                    break;
                case "极大":
                    //22,23,24,25,26,27
                    if (OpenSum >= 22 && OpenSum <= 27)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_JD && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_JD;
                    }
                    break;
                case "大单":
                    //15,17,19,21,23,25,27
                    if (OpenSum == 15 || OpenSum == 17 || OpenSum == 19 || OpenSum == 21 || OpenSum == 23 || OpenSum == 25 || OpenSum == 27)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_DD && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_DD;
                    }
                    break;
                case "小单":
                    //1,3,5,7,9,11,13
                    if (OpenSum == 1 || OpenSum == 3 || OpenSum == 5 || OpenSum == 7 || OpenSum == 9 || OpenSum == 11 || OpenSum == 13)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_XD && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_XD;
                    }
                    break;
                case "大双":
                    //14,16,18,20,22,24,26
                    if (OpenSum == 14 || OpenSum == 16 || OpenSum == 18 || OpenSum == 20 || OpenSum == 22 || OpenSum == 24 || OpenSum == 26)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_DS && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_DS;
                    }
                    break;
                case "小双":
                    //0,2,4,6,8,10,12
                    if (OpenSum == 0 || OpenSum == 2 || OpenSum == 4 || OpenSum == 6 || OpenSum == 8 || OpenSum == 10 || OpenSum == 12)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_XS && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_XS;
                    }
                    break;
                case "极小":
                    //0,1,2,3,4,5
                    if (OpenSum >= 0 && OpenSum <= 5)
                    {
                        model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_JX && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS);
                        Description1++;
                        WinMoney += (BuyAmount / 100) * (model.DefaultMoney / 100);
                        WinMoneyNoWithTax += (BuyAmount / 100) * (model.DefaultMoneyNoWithTax / 100);
                        WinCode = (int)XYEB_WinCodeEnum.DXDS_JX;
                    }
                    break;
            }
            if (Description1 > 0)
            {
                if (Convert.ToInt32(BuyNumber[1].Trim()) == SpecialNum)
                {
                    switch (SpecialNum)
                    {
                        case 0:
                            model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_TB0 && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS_TB);
                            WinMoney = WinMoney * (model.DefaultMoney / 100);
                            WinMoneyNoWithTax = WinMoney * (model.DefaultMoneyNoWithTax / 100);
                            WinCode = (int)XYEB_WinCodeEnum.DXDS_TB0;
                            break;
                        case 1:
                            model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_TB1 && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS_TB);
                            WinMoney = WinMoney * (model.DefaultMoney / 100);
                            WinMoneyNoWithTax = WinMoney * (model.DefaultMoneyNoWithTax / 100);
                            WinCode = (int)XYEB_WinCodeEnum.DXDS_TB1;
                            break;
                        case 2:
                            model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_TB2 && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS_TB);
                            WinMoney = WinMoney * (model.DefaultMoney / 100);
                            WinMoneyNoWithTax = WinMoney * (model.DefaultMoneyNoWithTax / 100);
                            WinCode = (int)XYEB_WinCodeEnum.DXDS_TB2;
                            break;
                        case 3:
                            model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_TB3 && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS_TB);
                            WinMoney = WinMoney * (model.DefaultMoney / 100);
                            WinMoneyNoWithTax = WinMoney * (model.DefaultMoneyNoWithTax / 100);
                            WinCode = (int)XYEB_WinCodeEnum.DXDS_TB3;
                            break;
                        case 4:
                            model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_TB4 && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS_TB);
                            WinMoney = WinMoney * (model.DefaultMoney / 100);
                            WinMoneyNoWithTax = WinMoney * (model.DefaultMoneyNoWithTax / 100);
                            WinCode = (int)XYEB_WinCodeEnum.DXDS_TB4;
                            break;
                        case 5:
                            model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_TB5 && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS_TB);
                            WinMoney = WinMoney * (model.DefaultMoney / 100);
                            WinMoneyNoWithTax = WinMoney * (model.DefaultMoneyNoWithTax / 100);
                            WinCode = (int)XYEB_WinCodeEnum.DXDS_TB5;
                            break;
                        case 6:
                            model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_TB6 && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS_TB);
                            WinMoney = WinMoney * (model.DefaultMoney / 100);
                            WinMoneyNoWithTax = WinMoney * (model.DefaultMoneyNoWithTax / 100);
                            WinCode = (int)XYEB_WinCodeEnum.DXDS_TB6;
                            break;
                        case 7:
                            model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_TB7 && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS_TB);
                            WinMoney = WinMoney * (model.DefaultMoney / 100);
                            WinMoneyNoWithTax = WinMoney * (model.DefaultMoneyNoWithTax / 100);
                            WinCode = (int)XYEB_WinCodeEnum.DXDS_TB7;
                            break;
                        case 8:
                            model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_TB8 && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS_TB);
                            WinMoney = WinMoney * (model.DefaultMoney / 100);
                            WinMoneyNoWithTax = WinMoney * (model.DefaultMoneyNoWithTax / 100);
                            WinCode = (int)XYEB_WinCodeEnum.DXDS_TB8;
                            break;
                        case 9:
                            model = wt.Find(p => p.WinCode == (int)XYEB_WinCodeEnum.DXDS_TB9 && p.PlayCode == (int)XYEB_PlayCodeEnum.DXDS_TB);
                            WinMoney = WinMoney * (model.DefaultMoney / 100);
                            WinMoneyNoWithTax = WinMoney * (model.DefaultMoneyNoWithTax / 100);
                            WinCode = (int)XYEB_WinCodeEnum.DXDS_TB9;
                            break;
                    }
                    Description = "大小单双-特别号码中奖," + Description1 + "注。";
                }
                else
                {
                    WinMoney = WinMoney / 2;
                    WinMoneyNoWithTax = WinMoneyNoWithTax / 2;
                    Description = "大小单双-特别号码未中," + Description1 + "注。";
                }
            }
            return WinMoney;
        }
        #endregion
        /// <summary>
        /// 非追号算奖(当前玩法没有追号)
        /// </summary>
        /// <param name="xml"></param>
        public override void ComputeWin(XmlNode xml)
        {
            List<udv_ComputeTicket> Sql = new List<udv_ComputeTicket>();
            List<long> ListWinSID = new List<long>();  //中奖记录方案号
            List<long> ListNoWinSID = new List<long>(); //没有中奖记录方案号
            List<long> NewListNoWinSID = new List<long>();
            List<udv_ComputeTicket> list = SchemeBLL.QueryComputeTicketList(LotteryCode);
            if (list == null || list.Count == 0) return;
            foreach (udv_ComputeTicket item in list)
            {
                string Description = "";
                long WinMoneyNoWithTax = 0;
                long WinMoney = 0;
                int WinCode = 0;
                if (item == null) continue;
                switch (item.PlayCode)
                {
                    case (int)XYEB_PlayCodeEnum.DXDS: //大小单双
                        WinMoney = ComputeWin_DXDS(item.Number, item.OpenNumber, item.TicketMoney, ref WinCode, ref Description, ref WinMoneyNoWithTax);
                        break;
                    case (int)XYEB_PlayCodeEnum.DXDS_TB: //大小单双_特别号码
                        WinMoney = ComputeWin_DXDS_TBHM(item.Number, item.OpenNumber, item.TicketMoney, ref WinCode, ref Description, ref WinMoneyNoWithTax);
                        break;
                    case (int)XYEB_PlayCodeEnum.CSZ: //猜数字
                        WinMoney = ComputeWin_CSZ(item.Number, item.OpenNumber, item.TicketMoney, ref WinCode, ref Description, ref WinMoneyNoWithTax);
                        break;
                    case (int)XYEB_PlayCodeEnum.QWW: //趣味玩
                        WinMoney = ComputeWin_QWW(item.Number, item.OpenNumber, item.TicketMoney, ref WinCode, ref Description, ref WinMoneyNoWithTax);
                        break;
                }

                item.LotteryCode = LotteryCode;
                item.WinCode = WinCode;
                item.SumWinMoney = WinMoney * item.Multiple * 100; //放大百倍
                item.SumWinMoneyNoWithTax = WinMoneyNoWithTax * item.Multiple * 100; //放大百倍
                item.Description = Description;

                Sql.Add(item);
                if (WinMoneyNoWithTax > 0 && !ListWinSID.Contains(item.SchemeID))
                    ListWinSID.Add(item.SchemeID);
                if (!ListNoWinSID.Contains(item.SchemeID))
                    ListNoWinSID.Add(item.SchemeID);
            }
            //过滤没有中奖的方案
            foreach (long item in ListNoWinSID)
            {
                if (ListWinSID.Contains(item))
                    continue;
                NewListNoWinSID.Add(item);
            }
            //处理中奖记录
            WinBLL.SchemesDetailsWin(Sql, ListWinSID, NewListNoWinSID);
            SchemeBLL.Redis_Compute(Sql);
        }
        #endregion
    }
}
